The present invention relates to retrieval of maximum and minimum values of vector data and, more particularly, to a vector data retrieval apparatus capable of retrieving element numbers corresponding to maximum or minimum values as retrieval results together with data.
FIG. 3 shows a conventional vector data retrieval apparatus. Referring to FIG. 3, reference numeral 1 denotes a vector data holding means for holding an ordered set of vector data; 2, a register in which vector data read out from the vector data holding means 1 is set; 3, an element number generating means for generating an element number corresponding to the vector data; 4, a register in which the element number generated by the element number generating means 3 is set; 5, a comparing means for comparing the data stored in the register 2 with data stored in a register 8 (to be described below) and outputting a selection signal T.sub.0 ; 6, a selecting means for selecting one of vector data F.sub.1 and F.sub.2 respectively stored in the registers 2 and 8 in response to the selection signal T.sub.0 ; 7, a selecting means for selecting one of element numbers G.sub.1 and G.sub.2 respectively stored in the register 4 and a register 9 (to be described below) in response to the selection signal T.sub.0 ; 8, the register for storing vector data selected by the selecting means 6; and 9, the register for storing an element number selected by the selecting means 7.
Note that, since element numbers are provided in one-to-one correspondence with vector data, they never coincide with each other but vary in value.
An operation of the vector data retrieval apparatus having the above-described arrangement will be described below. In the first cycle time, the first data of an ordered set of vector data is output from the vector holding means 1 and is set in the register 2. An element number corresponding to the vector data is generated by the element number generating means 3 and is set in the register 4. The data comparing means 5 compares the vector data stored in the register 2 with vector data stored in the register 8. In this case, however, since no vector data is stored in the register 8, the data comparing means 5 does not perform data comparison but generates a selection signal T.sub.0 for causing the selection means 6 and 7 to select the data stored in the registers 2 and 4, respectively. In the second cycle time, the second data held in the vector data holding means 1 is output and set in the register 2. An element number corresponding to this vector data is generated by the element number generating means and is set in the register 4. At the same time, the previous data in the registers 2 and 4, i.e., the first data of the ordered set of vector data and the corresponding element numbers, are respectively stored in the registers 8 and 9 in accordance with the selection signal T.sub.0, which is generated by the data comparing means 5 in the first cycle to cause the selecting means 6 and 7 to select the data. The data comparing means 5 compares values F.sub.1 andF.sub.2 of the vector data respectively stored in the registers 2 and 8, i.e., the second and first data of the vector data, with each other. The data comparing means 5 then generates and outputs a selection signal T.sub.0 for causing the selecting means 6 to select a larger value in response to an instruction of "maximum value retrieval" and to select a smaller value in response to an instruction of "minimum value retrieval". If the value of the vector data stored in the register 2 is equal to that of the vector data stored in the register 8, the data comparing means 5 always generates and outputs a selection signal T.sub.0 for causing the selecting means 6 to select the value set in the register 8. More specifically, the comparing means 5 receives the data F.sub.1 andF.sub.2 as comparison targets and generates the signal T.sub.0 for causing the selecting means 6 to select the data F.sub.1 if the instruction of "maximum value retrieval" is provided and F.sub.1 &gt;F.sub.2 If the instruction of "maximum value retrieval" is provided and F.sub.1 .ltoreq.F.sub.2, the comparing means 5 generates the signal T.sub.0 for causing the selection means 6 to select the data F.sub.2 The comparing means 5 generates the signal T.sub.0 for causing the selecting means 6 to select the data F.sub.1 if the instruction of "minimum value retrieval" is provided and F.sub.1 &lt;F.sub.2. If the instruction of "minimum value retrieval" is provided and F.sub.1 .gtoreq.F.sub.2, the comparing means 5 generates the signal T.sub.0 for causing the selection means 6 to select the data F.sub.2 The selection means 7 selects and outputs either an output G.sub.2 from the register 9, in which the element number corresponding to the first data of the vector data is stored, or an output G.sub.1 from the register 4, in which the element number corresponding to the second data of the vector data is stored, in accordance with the same selection signal T.sub.0 as supplied to the selecting means 6. Similarly, the maximum or minimum values of n vector data (n is a natural number) can be stored in the register 8 in the (n+1)th cycle time, and an element number corresponding to the maximum or minimum value stored in the register 8 can be stored in the register 9.
In the above-described conventional vector data retrieval apparatus, when data as comparison targets input to the data comparing means coincide with each other, an output from the same register (the register 8) is always selected. Therefore, if element numbers are input in an order of increasing values, a smaller number is selected as an element number assigned to a retrieval result. If element numbers are input in order of decreasing values, a larger number is selected as an element number assigned to a retrieval result. If element numbers are arbitrarily input, an arbitrary one of the element numbers is selected as an element number assigned to a retrieval result. Assume that a plurality of maximum or minimum values are present in vector data as retrieval targets. In this case, if the smallest element number is required as an element number assigned to a retrieval result, the vector data must be rearranged to be input to the vector data retrieval apparatus in an order of increasing element numbers. If the largest element number is required, the vector data must be rearranged to be input to the vector data retrieval apparatus in an order of decreasing element numbers. This undesirably increases the processing time as a whole.